//生成唯一订单号方法
	function setOutTradeNo(){
		var date = new Date();
		var orderNo = 'Y'+date.getFullYear()+''+(date.getMonth()+1)+''+date.getDate()+''+date.getHours()+''+date.getMinutes()+''+date.getSeconds()+''+Math.ceil(Math.random()*9)+''+Math.ceil(Math.random()*9)+''+Math.ceil(Math.random()*9)+''+Math.ceil(Math.random()*9)+''+Math.ceil(Math.random()*9);
		return orderNo;
	}
	
	/**
		 * 作用：退款时根据店铺id减去减去店铺的佣金
		 * @param {Object} shopId 店铺id
		 * @param {Object} money 需要减去的金额
		 */
	function setShopMoneyDec(shopId,money,orderNo){
			try{
				var db = uniCloud.database();
				var cmd = db.command;
				return db.collection('shop').where({_id:shopId}).update({
					money:cmd.inc(-money),
					refund_order_number:cmd.inc(1)
				});
			}catch(e){
				return e;
			}
			
		}
		
		/**
				 * 作用：更新订单状态
				 * @param orderNo 订单号
				 */
		function updateOrderStatus(orderNo){
				   try{
					   var db = uniCloud.database();
					   var cmd = db.command;
					   return db.collection('order_status').where({order_no:orderNo}).update({
					   	order_status:cmd.push({text:'订单取消',value:9,create_time:new Date().getTime()})
					   });
						return updateOrderStatusResult.updated;
					   
				   }catch(e){
					   return e;
				   }
					
				}
				
				/**
				 * 作用：插入平台佣金表
				 * @param {Object} data 要插入的数据
				 */
				function addPlatformBill(data,orderNo){
					try{
						var db = uniCloud.database();
						var cmd = db.command;
						return result = db.collection('platform_bill').add(data);
					}catch(e){
						return e;
					}
					
				}
				
				/**
				 *作用：插入店铺账单表
		
				 * @param {Object} data 要插入的数据
				 */
				function addToShopBill(data,orderNo){
					try{
						var db = uniCloud.database();
						var cmd = db.command;
						return db.collection('shop_bill').add(data);
						
					}catch(e){
						return e;
					}
					
				}
				
		/**
		 * 作用：插入用户日志表
		 * 
		 */
		async function addUsersLog(data,orderNo){
			try{
				var db = uniCloud.database();
				var cmd = db.command;
					const addUserLogResult = await db.collection('users_log').add(data);
					return addUserLogResult;
			}catch(e){
				return e;
			}
			
		}
		
		/**
		 * 作用：更新订单状态
		 * @param {Object} orderNo
		 */
	   function updateOrder(orderNo,text){
			try{
				var db = uniCloud.database();
				var cmd = db.command;
				return db.collection('orders').where({order_no:orderNo}).update({
					status:{
						text:'订单取消',
						value:9,
						create_time:new Date().getTime()
						},
						cancel_text:text
				})
			}catch(e){
				return e;
			}
			
		}

		/**
		 * 作用：点击申请退款更新商家金额、商家账单表、平台佣金表、状态表、订单表
		 */
		async function updateOrderData(orderData,orderNo,text){
			var db = uniCloud.database();
			var cmd = db.command;
			//减去商家的佣金
			const updateShopResult = await setShopMoneyDec(orderData.shop_id,orderData.advance_income_price,orderNo);
			
			if(updateShopResult.updated == 1){
				//查询出店铺信息
				const shopResult = await db.collection('shop').where({_id:orderData.shop_id}).get({getOne:true});
				const shop = shopResult.data[0];
				if(!orderData.my_name){
					//添加店铺账单表
					var shopBillData={
						shop_id:orderData.shop_id,//商家id，
						shop:{
							_id:orderData.shop_id,//商家id,
							title:shop.title,//店铺标题
							logo:shop.logo.url//店铺logo
						},
						order_no:orderData.order_no,//订单号
						order:{
							order_no:orderData.order_no,//订单号
							total_fee:orderData.total_fee,//订单金额
							delivery_fee:orderData.delivery_fee//配送费
						},
						type:2,//2代表出账
						user:{
							_id:orderData.user_id,//用户id,
							nickname:orderData.address.name,//收件人姓名
							avatar:orderData.address.avatar//用户头像
						},
						price:orderData.advance_income_price,//扣除金额
						text:'订单退款',
						is_settlement:{
							is_true:true,//自动已结算
							create_time:new Date().getTime()
						},
						create_date:new Date().getTime()
						
					}
								
					const addShopBill = await addToShopBill(shopBillData,orderNo);
					
					if(addShopBill.id){
						//从平台佣金表减去佣金
						var date = new Date();
						var today = date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
						const platform = {
							text:'订单退款',
							status:3,//退款为3
							price:-orderData.platform_commission,//减去的佣金额度
							type:2,//出账为2
							order:{
								order_no:orderData.order_no,//订单号
								price:orderData.total_fee,//订单金额
								delivery_fee:orderData.delivery_fee,//配送费
								shop_title:shop.title,//店铺标题
								shop_id:orderData.shop_id,//店铺id，
								user_id:orderData.user_id,//用户id
								user_nickname:orderData.address.name,//收件人姓名
								distance:orderData.distance,//距离
								deduct_delivery_price:orderData.deduct_delivery_price //实际扣除佣金
							},
							create_date:{
								time_stamp:new Date().getTime(),
								today:today
							}
						}
						
						
						//插入平台佣金表
						const addPlatformResult = await addPlatformBill(platform,orderNo);
						
						if(addPlatformResult.id){
							//更新订单表和订单状态表
							const updateOrderStatusResult = await updateOrderStatus(orderNo);
							
							if(updateOrderStatusResult.updated==1){
								
								//更新订单状态
								const updateOrderResult = await updateOrder(orderNo,text);
								if(updateOrderResult.updated==1){
									return true;
								}
								
							}
						}
						
						
					}
					
				}else{
					//从平台佣金表减去佣金
					var date = new Date();
					var today = date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
					const platform = {
						text:'订单退款',
						status:3,//退款为3
						price:-orderData.platform_commission,//减去的佣金额度
						type:2,//出账为2
						order:{
							order_no:orderData.order_no,//订单号
							price:orderData.total_fee,//订单金额
							delivery_fee:orderData.delivery_fee,//配送费
							shop_title:shop.title,//店铺标题
							shop_id:orderData.shop_id,//店铺id
							user_id:orderData.user_id,//用户id
							distance:orderData.distance,//距离
							deduct_delivery_price:orderData.deduct_delivery_price //实际扣除佣金
						},
						create_date:{
							time_stamp:new Date().getTime(),
							today:today
						}
					}
					
					
					//插入平台佣金表
					const addPlatformResult = await addPlatformBill(platform,orderNo);
					
					if(addPlatformResult.id){
						//更新订单表和订单状态表
						const updateOrderStatusResult = await updateOrderStatus(orderNo);
						
						if(updateOrderStatusResult.updated==1){
							
							//更新订单状态
							const updateOrderResult = await updateOrder(orderNo,text);
							if(updateOrderResult.updated==1){
								return true;
							}
							
						}
					}
				}
				
				
			
			}
		}
		
		
module.exports = {
	addOrderTouniPayOrders(data){
		data.out_trade_no=setOutTradeNo();
		const db = uniCloud.database();
		
		return db.collection('orders').add(data);
	},
	//插入平台佣金表
	insertToPlatformBill(data){
		const dbJQL = uniCloud.databaseForJQL({
		clientInfo: this.getClientInfo()
		});
		return dbJQL.collection('platform_bill').add(data);
	},
	//更新订单状态为已取消
	updateOrderStatusToCancel(orderNo,data){
		const db = uniCloud.database();
		var cmd = db.command;
		return db.collection('order_status').where({order_no:orderNo}).update({
			order_status:cmd.push(data)
		});
	},
	//更新店铺的评价数量
	updateShopCommentCount(shopId){
		const db = uniCloud.database();
		var cmd = db.command;
		return db.collection('shop').where({_id:shopId}).update({
			order_status:cmd.inc(1)
		});
	},
	//增加评论的点赞数量
	setLikeNumber(id){
		const db = uniCloud.database();
		var cmd = db.command;
		return db.collection('comment').where({_id:id}).update({
			like_number:cmd.inc(1)
		});
	},
	/**
	 * @param {Object} shopId 商家表_id
	 * @param {Object} money 增加的金额
	 */
	updateShopMoney(shopId,money,totalSales){
		const db = uniCloud.database();
		return	db.collection("shop").where({_id:shopId}).update({
			  money: db.command.inc(money),
			  total_sales:db.command.inc(totalSales)
			})
		},
		
		/**
		 * 作用：提现时调用此方法
		 * @param {Object} shopId 商家表_id
		 * @param {Object} money 增加的金额
		 */
		updateShopMoneyByWithdrawal(shopId,money){
			const db = uniCloud.database();
			return	db.collection("shop").where({_id:shopId}).update({
				  money: db.command.inc(money)
				})
			},
			
	/**
		 * 修改订单表删除rider字段
		 * @param table {string}	表名
		 * @param where {Object}	筛选条件 	*/
		updateDeleteField(where){
		const db = uniCloud.database();
		return	db.collection("orders").where(where).update({
			  rider: db.command.remove()
			})
		},
		
		/**
		 * 作用：处理订单退款
		 * 说明：如果是用户端发起，则只要该订单还没有被接单则随时可以发起退款且不需要商家同意
		 * 如果是商家发起退款，则直接执行退款操作，不需要买家同意。
		 * 
		 * 
		 */
		async orderRefund(orderNo,isShop=false,text=''){
			//查询出订单信息
			var db = uniCloud.database();
			var cmd = db.command;
			//如果是商家退款，要判断订单状态是否为骑手未取货
			const orders = await db.collection('orders').where({order_no:orderNo}).get({getOne:true});
			var orderData = orders.data[0];
			//如果是商家，则在骑手未取餐之前可以直接退款
			if(isShop==true){
				
				if(orderData.status.value <4 && orderData.status.value > 0){
					const updateOrderResult = updateOrderData(orderData,orderNo,text);
					if(orderData.rider && orderData.rider.user_id){
						//删除骑手账单表和减去骑手订单数量
						await db.collection('rider_users').where({_id:orderData.rider.user_id}).update({
							order_total_number:cmd.inc(-1),
							order_number:cmd.inc(-1)
						});
						//删除对应的账单
						db.collection('rider_bill').where({"order.order_no":orderData.order_no}).remove();
					}
					
					return updateOrderResult;
				}else{
					return '订单当前状态不支持退款';
				}
			}else{
				if(orderData.status.value==1){
					const updateOrderResult = updateOrderData(orderData,orderNo,text);
					if(orderData.rider && orderData.rider.user_id){
						//删除骑手账单表和减去骑手订单数量
						await db.collection('rider_users').where({_id:orderData.rider.user_id}).update({
							order_total_number:cmd.inc(-1),
							order_number:cmd.inc(-1)
						});
						//删除对应的账单
						db.collection('rider_bill').where({"order.order_no":orderData.order_no}).remove();
					}
					
					return updateOrderResult;
				}else{
					return '订单当前状态不支持退款';
				}
			}
			
			
		},
		
		/**
		 * 作用：增加订单表orders退款金额总数和团派表group_buying表的退款金额总数
		 * @param {string} orderNo 订单号
		 * @param {int} money 要增加的金额
		 */
	 async setOrdersAndGroupBuyingMoney(orderNo,money){
			var db = uniCloud.database();
			const ordersResult = await db.collection('orders').where({order_no:orderNo}).update({
				refund_total_price:db.command.inc(money)
			});
			
			const groupBuyingResult = await db.collection('group_buying').where({order_no:orderNo}).update({
				refund_total_price:db.command.inc(money)
			});
			
			if(ordersResult.updated==1 && groupBuyingResult.updated==1){
				return 1;
			}
			
		},
		
		/**
		 * 作用：更新店铺和商品销量
		 * @param {string} orderNo 订单号
		 * @param {int} act 1：增加，2：减少
		 * 
		 */
		async updateShopAndGoodsSales(orderNo,act=1){
			var db = uniCloud.database();
			var cmd = db.command;
			//查询出对应的订单
			const order = await db.collection('orders').where({order_no:orderNo}).get({getOne:true});
			var orderData = order.data[0];
			const goods = orderData.goods;
			//增加商品销量
			var totalSales = 0;
			for(var i = 0;i<goods.length;i++){
				var id = goods[i]._id;
				var number = goods[i].number;
				totalSales += number;
				db.collection('goods').where({_id:id}).update({
					total_sales:cmd.inc(number)
				});
			}
			
			return db.collection('shop').where({_id:orderData.shop_id}).update({
				total_sales:cmd.inc(totalSales)
			});
			
			
		},
		
		//用户支付成功后更新订单状态表，平台佣金表和商家账单表
		async insertOrderStatusAndPlatformBill(orderNo){
			var db = uniCloud.database();
			var cmd = db.command;
			const order = await db.collection('orders').where({order_no:orderNo}).get({getOne:true});
			const orderData = order.data[0];
			var score = parseInt(orderData.total_fee/100);
			//增加用户积分
			db.collection('uni-id-users').where({_id:orderData.user_id}).update({
				score:db.command.inc(score)
			});
				
			
			//查询出店铺信息
			const shop = await db.collection('shop').where({_id:orderData.shop_id}).get({getOne:true});
			const shopData = shop.data[0];
			
			var todayDate = new Date();
			var platform={
				create_date:{
					time_stamp:todayDate.getTime(),
					today:todayDate.getFullYear()+'-'+(todayDate.getMonth()+1)+'-'+todayDate.getDate()
				},
				
				text:'订单佣金',
				price:orderData.platform_commission,
				type:1,
				order:{
					order_no:orderData.order_no,
					price:orderData.total_fee,
					delivery_fee:orderData.deduct_delivery_price,
					shop_title:shopData.title,
					shop_id:shopData._id,//店铺id
					user_id:orderData.user_id,
					user_nickname:orderData.address.name,
					distance:orderData.distance,
					deduct_delivery_price:orderData.deduct_delivery_price
				}
				
			}
			
			//插入平台账单表
			await db.collection('platform_bill').add(platform);
			if(!orderData.my_name){
				//插入商家佣金表
				const shopBill = {
					shop_id:shopData._id,//店铺id
					shop:{
						_id:shopData._id,
						title:shopData.title,
						logo:shopData.logo.url
					},
					order_no:orderData.order_no,//订单号
					order:{
						order_no:orderData.order_no,//订单号
						total_fee:orderData.total_fee,//订单总金额
						delivery_fee:orderData.delivery_price,//配送费
						
					},
					type:1,//进账类型
					user:{
						_id:orderData.user_id,//用户id
						nickname:orderData.address.name,//用户昵称
						avatar:orderData.address.avatar//用户头像
					},
					price:orderData.advance_income_price,//进账金额 
					text:'订单收入',
					create_date:new Date().getTime()
				}
				
				
				await db.collection('shop_bill').add(shopBill);
				 //更新到商家表，增加商家佣金
				await db.collection('shop').where({_id:shopData._id}).update({
					money:cmd.inc(orderData.advance_income_price)
				});
			}
			
			
			
			
			var apiUrl = 'https://api.yipaidaojia.com/index.php/api/aliyun_voice';
			await uniCloud.httpclient.request(apiUrl, {
			    method: 'POST',
			    data: {
			      token: '86f24d4bf67694706a347dc36f3365c0',
			      tel:shopData.tel
			    },
			    contentType: 'json', // 指定以application/json发送data内的数据
			    dataType: 'json' // 指定返回值为json格式，自动进行parse
			  })
			  
			  
			//推送给卖家
			var push = uniCloud.importObject('push',{customUI:true});
			//商家uid
			const shopUserId = shopData.create_uid;
			if(shopUserId=='64d5f86286206658e9bb7afe'){
				var appId = '__UNI__DC7EAB3';
			}else{
				var appId = '__UNI__1EEA680';
				var pcAppId = '__UNI__AC500DC';
			}
			const title = '新的订单消息';
			const content = '您有新的易派到家订单，请尽快处理';
			const payLoad={
				"order_no":orderData.order_no,
				type:1
			}
			push.sendMessage(appId,shopUserId,title,content,payLoad);
			push.sendMessage(pcAppId,shopUserId,title,content,payLoad);
			//推送给客服后台
			const yipaiAppId = '__UNI__DC7EAB3';
			const userId = '64d5f86286206658e9bb7afe';
			const yipaiTitle = '新的订单消息';
			const yipaiContent = '您有新的易派到家订单，请尽快处理';
			const yipaiPayLoad={
				"order_no":orderData.order_no,
				type:1
			}
			
			if(shopUserId!=userId){
				push.sendMessage(yipaiAppId,userId,yipaiTitle,yipaiContent,yipaiPayLoad);
				push.sendMessageByClientId(yipaiAppId,['6564109ba7c432f4178a43e4','6483c9fef43e60ba7fd48b48','648fa54de766bb769179489b','646e23fe09e2989198b374e6'],yipaiTitle,yipaiContent,yipaiPayLoad);
			}
			
			//更新商品和店铺销量
			const orderObject = uniCloud.importObject('order',{customUI:true});
			orderObject.updateShopAndGoodsSales(orderData.order_no);
			
			
			//推送给管理端
			const deviceData = await db.collection('opendb-device').where({appid:'__UNI__EE8F8DE'}).get();
			const device = deviceData.data;
			
			var clientId = [];
			for (var i = 0; i < device.length; i++) {
				clientId.push(device[i].push_clientid);
			}
			if (clientId.length > 0) {
				const uniPush = uniCloud.getPushManager({
					appId: '__UNI__EE8F8DE',
				}) //注意这里需要传入你的应用appId
				return uniPush.sendMessage({
					"push_clientid": clientId,
					"title": '新订单',
					"content": '有新订单',
					"payload": {
						type:1,
						orderNo:orderData.order_no
					}
				})
			} else {
				return '未找到对应的cid'
			}
			//push.sendMessageToManagement(device,orderData.order_no);
			
			
		},
		/**
		 * 作用：接单后自动分配骑手
		 * @param {Object} order:订单信息
		 * @param {bool} isErrands:是否为跑腿订单
		 */
		async allocationRider(order,isErrands=null){
			var db = uniCloud.database();
			var cmd = db.command;
			if(isErrands!=1){
			//查询出店铺位置
			var shopData = await db.collection('shop').where({_id:order.shop_id}).get();
			var shop = shopData.data[0];
			//获取店铺所对应的乡镇
			var areaCode = shop.area.value;
			var location = shop.location;
				//根据乡镇编号查询出对应的骑手信息
				var riderData = await db.collection('rider_users').where({
					"area.value":areaCode,
					status:true,
					is_online:true,
					location:db.command.geoNear({
						geometry: new db.Geo.Point(location.coordinates[0], location.coordinates[1]),
						maxDistance: 10000,
						minDistance: 0
					  })
				}).get({getOne:true});
			}else{
				var end = order.end;
				if(end==1){
					var lng = order.my_location_jian.lng;
					var lat = order.my_location_jian.lat;
				}else if(end==2){
					var lng = order.side_location_jian.lng;
					var lat = order.side_location_jian.lat;
				}
				//根据乡镇编号查询出对应的骑手信息
				var riderData = await db.collection('rider_users').where({
					status:true,
					is_online:true,
					location:db.command.geoNear({
						geometry: new db.Geo.Point(lng, lat),
						maxDistance: 100000,
						minDistance: 0
					  })
				}).get({getOne:true});
			}
			
			var rider = riderData.data[0];
			//将查询的骑手信息更新到订单表
			var data = {
				avatar:rider.avatar,
				connect_time:new Date().getTime(),
				mobile:rider.mobile,
				nickname:rider.name,
				user_id:rider._id
			}
			
			var updateRiderResult = await db.collection('orders').where({order_no:order.order_no}).update({rider:data});
			if(updateRiderResult.updated==1){
				
				//增加骑手的订单总数量和进行中的数量
				await db.collection('rider_users').where({_id:rider._id}).update({
					order_total_number:cmd.inc(1),
					order_number:cmd.inc(1)
				});
				//插入骑手账单表
				var date = new Date();
				var timestampDate = date.getTime();
				var today = (date.getMonth()+1)+'-'+date.getDay();
				var month = date.getMonth()+1;
				var riderBillData = {
					 "price": order.deduct_delivery_price,
					    "rider_id": rider._id,
					    "user_id": order.user_id,
					    "shop_id": order.shop_id,
					    "order": {
					        "order_no": order.order_no,
					        "total_fee": order.total_price,
					        "delivery_fee": order.delivery_price
					    },
					    "type": 1,
					    "text": "配送佣金",
					    "status": 1,
					    "create_date": {
					        "timestamp": timestampDate,
					        "date": today,
					        "month": month
					    }
				}
				//插入骑手佣金表
				db.collection('rider_bill').add(riderBillData);
				var apiUrl = 'https://api.yipaidaojia.com/index.php/api/aliyun_voice';
				await uniCloud.httpclient.request(apiUrl, {
				    method: 'POST',
				    data: {
				      token: '86f24d4bf67694706a347dc36f3365c0',
				      tel:rider.mobile
				    },
				    contentType: 'json', // 指定以application/json发送data内的数据
				    dataType: 'json' // 指定返回值为json格式，自动进行parse
				  })
				  
				  //推送给骑手
				  var riderDevice = await db.collection('uni-id-device').where({user_id:rider.user_id}).get();
				  var riderCid = riderDevice.data;
				  var pushClientid = [];
				  for(var i = 0;i<riderCid.length;i++){
					  pushClientid.push(riderCid[i].push_clientid);
				  }
				  //推送给骑手
				 const uniPush = uniCloud.getPushManager({
				 	appId: '__UNI__89628D0',
				 }) //注意这里需要传入你的应用appId
				uniPush.sendMessage({
				 	"push_clientid": pushClientid,
				 	"title": '新订单',
				 	"content": '有新订单',
				 	"payload": {
				 		type:1,
				 		orderNo:order.order_no
				 	}
				 })
				  
			}
			
			
			  
		},
		//接单后将骑手信息更新到订单表
		async setRiderToOrder(rider,orderNo){
			var db = uniCloud.database();
			var cmd = db.command;
			var data = {
				avatar:rider.avatar,
				connect_time:new Date().getTime(),
				mobile:rider.mobile,
				nickname:rider.name,
				user_id:rider._id
			}
			//查询出对应的订单的骑手信息并减去骑手对应的数量和从订单表删除
			var orderResult = await db.collection('orders').where({order_no:orderNo}).get();
			var orderData = orderResult.data[0];
			var date = new Date();
			var timestampDate = date.getTime();
			var today = (date.getMonth()+1)+'-'+date.getDay();
			var month = date.getMonth()+1;
			//插入骑手账单表
			var riderBillData = {
				 "price": orderData.deduct_delivery_price,
				    "rider_id": rider._id,
				    "user_id": orderData.user_id,
				    "shop_id": orderData.shop_id,
				    "order": {
				        "order_no": orderData.order_no,
				        "total_fee": orderData.total_price,
				        "delivery_fee": orderData.deduct_delivery_price
				    },
				    "type": 1,
				    "text": "配送佣金",
				    "status": 1,
				    "create_date": {
				        "timestamp": timestampDate,
				        "date": today,
				        "month": month
				    }
			}
			
			if(orderData && orderData.rider && orderData.rider.user_id){
				var riderId = orderData.rider.user_id;
				//删除之前骑手对应的账单
				await db.collection('rider_bill').where({"order.order_no":orderData.order_no}).update({
					rider_id:rider._id
				});
				var updateRiderResult = await db.collection('orders').where({order_no:orderNo}).update({rider:data});
				if(updateRiderResult.updated==1){
					//减少之前骑手的对应的数量
					db.collection('rider_users').where({_id:riderId}).update({
						order_total_number:cmd.inc(-1),
						order_number:cmd.inc(-1)
					});
					
					db.collection('rider_users').where({_id:rider._id}).update({
						order_total_number:cmd.inc(1),
						order_number:cmd.inc(1)
					});
					
					
				}
			}else{
				var updateRiderResult = await db.collection('orders').where({order_no:orderNo}).update({rider:data});
				if(updateRiderResult.updated==1){
					//插入骑手佣金表
					db.collection('rider_bill').add(riderBillData);
					db.collection('rider_users').where({_id:rider._id}).update({
						order_total_number:cmd.inc(1),
						order_number:cmd.inc(1)
					});
				}
			}
			
			
			
			var apiUrl = 'https://api.yipaidaojia.com/index.php/api/aliyun_voice';
			await uniCloud.httpclient.request(apiUrl, {
			    method: 'POST',
			    data: {
			      token: '86f24d4bf67694706a347dc36f3365c0',
			      tel:rider.mobile
			    },
			    contentType: 'json', // 指定以application/json发送data内的数据
			    dataType: 'json' // 指定返回值为json格式，自动进行parse
			  })
			  
		}
		
		
		
		
}
